<?php
require_once("taskView.php");
require_once(CORE_DIR.'taskModel.php');

class movedailytaskAction extends authAction{

	function __construct(){
		$this->view = new taskView();
	}

	public function run($get, $post, $viewtype) {
		parent::run($get,$post,$viewtype);
		
		$tModel = new taskModel();
		$date = "";
		if (isset($get['date'])) //date format is 2011-03-12
		{
			$strDate = $get['date'];
			$arrDate = explode("-", $strDate);
			if ((count($arrDate) == 3) && (checkdate($arrDate[1], $arrDate[2], $arrDate[0])) )
				$date = $strDate;			
		}
		

		if (isset($get["id"]) && $date != "")
		{
			$tskId = $get["id"];
			$status = 0;
			if ($tModel->moveDailyTask($tskId, $date))
			{
				$status = 1;
				$lastInsertId = $tskId;
			}
		
			$this->view->setProperty("status", $status);
			$this->view->setProperty("id", $lastInsertId);
			$this->view->showAddTask();
		}
		else{
			$this->view->showBadCmd();
		}	
			
	}
}
?>